<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:order:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="工单号" align="center" prop="gdCode" />
      <el-table-column label="优先级" align="center" prop="gdGoodlevel" :formatter="gdLevel"/>
      <el-table-column label="工单状态" align="center" prop="gdStatus" :formatter="gdStatus" width="100"/>
      <el-table-column label="负责人" align="center" prop="responsibility" />
      <el-table-column label="订单号" align="center" prop="ddCode" />
      <el-table-column label="产品批次" align="center" prop="cpCppcCode" />
      <el-table-column label="产品编码" align="center" prop="cpCode" />
      <el-table-column label="产品名称" align="center" prop="cpProduct.cpName"  width="100"/>
      <el-table-column label="产品型号" align="center" prop="cpProduct.cpType" width="80"/>
      <el-table-column label="任务数量" align="center" prop="workNum" width="80"/>
      <el-table-column label="完成数量" align="center" prop="wcNum" width="80"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:order:edit']"
          >详情</el-button>
          <el-button
            v-if="scope.row.gdStatus == '3'"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="updateGdStatus(scope.row,'开工')"
            v-hasPermi="['system:order:remove']"
          >开工</el-button>

          <el-button
            v-if="scope.row.gdStatus == '4'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="updateGdStatus(scope.row,'恢复')"
            v-hasPermi="['system:order:edit']"
          >恢复</el-button>

          <el-button
            v-if="scope.row.gdStatus == '1'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="gdReport(scope.row)"
            v-hasPermi="['system:order:edit']"
          >报工</el-button>

          <el-button
            v-if="scope.row.gdStatus == '1'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="updateGdStatus(scope.row,'完工')"
            v-hasPermi="['system:order:edit']"
          >完工</el-button>

          <el-button
            v-if="scope.row.gdStatus == '1'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="updateGdStatus(scope.row,'暂停')"
            v-hasPermi="['system:order:edit']"
          >暂停</el-button>

          <el-button
            v-if="scope.row.gdStatus == '1'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="getWlList(scope.row)"
            v-hasPermi="['system:order:edit']"
          >物料需求</el-button>

          <el-button
            v-if="scope.row.gdStatus == '1' || scope.row.gdStatus == '4' || scope.row.gdStatus == '5'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:order:edit']"
          >报工记录</el-button>

        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!--工单详情-->
    <el-dialog :title="scgdTitle" :visible.sync="scgdSelected" width="600px" append-to-body>
      <div class="dialog-content">
        <el-form ref="form" :model="form" label-width="120px" style="font-size: 10px">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="工单优先级：" prop="gdGoodlevel">
                <span>{{ form.gdGoodlevel }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="订单号：" prop="scddProductionOrderForm.ddCode">
                <span>{{ form.scddProductionOrderForm.ddCode }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="工单客户：" prop="scddProductionOrderForm.ksMerchant.merchantsName">
                <span>{{ form.scddProductionOrderForm.ksMerchant.merchantsName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="合同编号：" prop="scddProductionOrderForm.htCode">
                <span>{{ form.scddProductionOrderForm.htCode }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="产品名称：" prop="scddProductionOrderForm.cpProduct.cpName">
                <span>{{ form.scddProductionOrderForm.cpProduct.cpName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="产品编码：" prop="scddProductionOrderForm.cpCode">
                <span>{{ form.scddProductionOrderForm.cpCode }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="产品型号：" prop="scddProductionOrderForm.cpProduct.cpType">
                <span>{{ form.scddProductionOrderForm.cpProduct.cpType }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="负责人：" prop="responsibility">
                <span>{{ form.responsibility }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="任务数量：" prop="workNum">
                <span>{{ form.workNum }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="交货日期：" prop="jhDate">
                <span>{{ form.jhTime }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="开始时间：" prop="startTime">
                <span>{{ form.startTime }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="完成时间：" prop="finishTime">
                <span>{{ form.endTime }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              <el-form-item label="备注：" prop="other">
                <span>{{ form.other }}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>


        <!-- 标签页部分 -->
        <el-tabs v-model="activeTab">
          <el-tab-pane label="生产BOM" name="bom">
            <el-table :data="bomData" style="width: 100%">
              <el-table-column prop="wlName" label="物料名称" show-overflow-tooltip></el-table-column>
              <el-table-column prop="wlCode" label="物料编码" show-overflow-tooltip></el-table-column>
              <el-table-column prop="wlTypecode" label="物料类型" show-overflow-tooltip>
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.wl_type" :value="scope.row.wlTypecode"/>
                </template>
              </el-table-column>
              <el-table-column prop="wlGg" label="物料规格" show-overflow-tooltip></el-table-column>
              <el-table-column prop="jldwMeasurementUnit.dwName" label="物料单位" show-overflow-tooltip></el-table-column>
              <el-table-column prop="wlFormcode" label="物料来源" show-overflow-tooltip>
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.wl_from" :value="scope.row.wlFormcode"/>
                </template>
              </el-table-column>
              <el-table-column prop="wlMaterialsAndMesBom.many" label="基本用量" show-overflow-tooltip></el-table-column>
            </el-table>
          </el-tab-pane>

          <el-tab-pane label="产品属性" name="attributes">
            <!-- 产品属性内容 -->
            <el-table :data="attributesData" style="width: 100%">
              <el-table-column prop="sxName" label="属性名称"></el-table-column>
              <el-table-column prop="sxValue" label="属性值"></el-table-column>
            </el-table>
          </el-tab-pane>

        </el-tabs>

      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="scgdBtn">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="bgTitle" :visible.sync="bgSelected" width="740px" append-to-body>
      <div class="dialog-content">
        <el-form ref="form" :model="forms" label-width="120px">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="生产工单号：" prop="workOrderNumber">
                <span>{{ forms.workOrderNumber }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="产品批次号：" prop="productBatchNumber">
                <span>{{ forms.productBatchNumber }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="产品名称：" prop="productName">
                <span>{{ forms.productName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="产品型号：" prop="productModel">
                <span>{{ forms.productModel }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="任务数量：" prop="taskQuantity">
                <span>{{ forms.taskQuantity }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="已报工数量：" prop="reportedQuantity">
                <span>{{ forms.reportedQuantity }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="选择工序：" prop="selectedProcess">
                <el-select v-model="forms.selectedProcess" placeholder="请选择">
                  <el-option label="工序1" value="process1"></el-option>
                  <el-option label="工序2" value="process2"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="报工班组：" prop="reportingTeam">
                <el-select v-model="forms.reportingTeam" placeholder="请选择">
                  <el-option label="生产班组1" value="team1"></el-option>
                  <el-option label="生产班组2" value="team2"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="报工方式：" prop="reportingMethod">
                <el-select v-model="forms.reportingMethod" placeholder="请选择">
                  <el-option label="合并报工" value="combined"></el-option>
                  <el-option label="单独报工" value="individual"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="table-qyh">
            <el-divider content-position="center">生产报工</el-divider>
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-plus" size="mini" @click="addProductionReport">添加</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="danger" icon="el-icon-delete" size="mini" @click="removeProductionReport">删除</el-button>
              </el-col>
            </el-row>
            <el-table :data="forms.productionReport" >
              <el-table-column type="selection" width="50" align="center" />
              <el-table-column label="报工人员" prop="reportWorker" width="140">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.reportWorker" readonly @click.native="getUsers" suffix-icon="el-icon-more"/>
                </template>
              </el-table-column>
              <el-table-column label="生产数量" prop="productionQuantity" width="140">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.productionQuantity" placeholder="请输入" />
                </template>
              </el-table-column>
              <el-table-column label="合格数量" prop="qualifiedQuantity" width="140">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.qualifiedQuantity" placeholder="请输入" />
                </template>
              </el-table-column>
              <el-table-column label="不合格数量" prop="unqualifiedQuantity" width="140">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.unqualifiedQuantity" placeholder="请输入" />
                </template>
              </el-table-column>
              <el-table-column label="操作" width="100">
                <template slot-scope="scope">
                  <el-button type="text" @click="removeProductionReport(scope.$index)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>


        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="scgdBtn">确 定</el-button>
      </div>
    </el-dialog>


    <!--物料需求弹窗-->
    <el-dialog title="物料需求" :visible.sync="dialogVisible" width="740px"  append-to-body>
      <div class="dialog-content" style="height: 600px">
        <el-table :data="bomData" style="width: 100%">
          <el-table-column prop="wlCode" label="物料编码" width="100" />
          <el-table-column prop="wlName" label="物料名称" width="100" />
          <el-table-column prop="wlGg" label="物料规格" width="100" />
          <el-table-column prop="jldwMeasurementUnit.dwName" label="单位" width="80" />
          <el-table-column prop="wlFormcode" label="物料来源" width="100" >
            <template slot-scope="scope">
              <dict-tag :options="dict.type.wl_type" :value="scope.row.wlTypecode"/>
            </template>
          </el-table-column>
          <el-table-column prop="wlMaterialsAndMesBom.many" label="需求数量" width="80" :formatter="numSum"/>
          <el-table-column label="申请数量" width="120">
            <template slot-scope="scope">
              <el-input v-model="scope.row.applicationQuantity" placeholder="请输入申请数量" />
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitForm">提交</el-button>
      </div>
    </el-dialog>

    <!-- 用户管理弹框 -->
    <el-dialog title="选择负责人" :visible.sync="userSelect" width="30%">
      <el-container>
        <el-header>
          <el-input suffix-icon="el-icon-search" v-model="userName"
          ></el-input>
        </el-header>
        <el-main>
          <!-- 选择报工人员 -->
          <el-table border :data="userList" @row-dblclick="updateUser">
            <el-table-column prop="userName" label="人员名称" width="140px"></el-table-column>
            <el-table-column prop="dept.deptName" label="部门"></el-table-column>
            <el-table-column prop="sex" label="性别" :formatter="getSex"></el-table-column>
          </el-table>
        </el-main>
      </el-container>
    </el-dialog>

  </div>
</template>

<script>
import {
  listOrder,
  getOrder,
  delOrder,
  addOrder,
  updateOrder,
  listBom,
  getCpAttribute,
  updateGdStatus
} from "@/api/order/order";
import {listForm} from "@/api/scdd/form";
import { listUser} from "@/api/system/user";

export default {
  name: "Order",
  dicts: ['wl_from', 'wl_type', 'wl_sortcode','jsdw_unit_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      //产品属性集合
      attributesData:[],
      //报工弹窗标题
      bgTitle:'生产报工',
      //显示报工弹窗
      bgSelected:false,
      // 子表选中数据
      checkedScddProductionOrderForm: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      //工单标题
      scgdTitle:"工单详情",
      //工单弹窗显示
      scgdSelected:false,
      activeTab: 'bom',
      //Bom列表
      bomData:[],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产工单表格数据
      orderList: [],
      // 生产订单表格数据
      scddProductionOrderFormList: [],
      // 弹出层标题
      title: "",
      //订单信息
      scddList:[],
      //用户列表
      userList:[],
      //弹出选择用户
      userSelect:false,
      //用户分页
      userTotal:0,
      //物料需求弹窗
      dialogVisible:false,
      //物料需求集合
      materialData: [
        {
          materialCode: '001',
          materialName: '物料A',
          materialSpec: '规格A',
          unit: '个',
          materialSource: '来源A',
          requiredQuantity: 100,
          applicationQuantity: 0
        },{
          materialCode: '001',
          materialName: '物料A',
          materialSpec: '规格A',
          unit: '个',
          materialSource: '来源A',
          requiredQuantity: 100,
          applicationQuantity: 0
        },{
          materialCode: '001',
          materialName: '物料A',
          materialSpec: '规格A',
          unit: '个',
          materialSource: '来源A',
          requiredQuantity: 100,
          applicationQuantity: 0
        },
        // 可以继续添加更多的物料数据
      ],
      //用户姓名
      userName:null,
      //订单分页参数
      scddTotal:0,
      //生产订单号
      scddCode:null,
      //弹出选择订单
      ddSelect:false,
      // 是否显示弹出层
      open: false,
      //任务数量
      rwNum:null,
      //选中的工单号
      gdCode: null,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        gdGoodlevel: null,
        gdStatus: null,
        ddCode: null,
        htCode: null,
        cpCode: null,
        ksCode: null,
        workNum: null,
        jhTime: null,
        startTime: null,
        endTime: null,
        other: null,
        isUse: null,
        isDelete: null,
        percent: null,
        scgdCreate: null,
        createTime: null,
        updateTime: null
      },
      // 表单参数
      form:{},
      forms: {
        workOrderNumber: "WO123456",
        productBatchNumber: "PB123456",
        productName: "产品A",
        productModel: "型号A",
        taskQuantity: 100,
        reportedQuantity: 50,
        selectedProcess: "",
        reportingTeam: "",
        reportingMethod: "",
        productionReport: []
      },
      // 表单校验
      rules: {
        gdGoodlevel: [
          { required: true, message: "工单优先级不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {


    addProductionReport() {
      this.forms.productionReport.push({
        reportWorker: "",
        productionQuantity: "",
        qualifiedQuantity: "",
        unqualifiedQuantity: ""
      });
    },
    removeProductionReport(index) {
      this.forms.productionReport.splice(index, 1);
    },


    /**选择负责人*/
    updateUser(){},

    /** 需求数量计算 */
    numSum(row, column, cellValue){
      let many=Number(cellValue);
      let workNum=Number(this.rwNum);
      console.log(row)
      return many*workNum;
    },

    /** 查询生产工单列表 */
    getList() {
      this.reset();
      this.loading = true;
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows;
        console.log(response.rows)
        this.total = response.total;
        this.loading = false;
      });
    },
    /**展示详情*/
    scgdBtn(){
      console.log("确认按钮点击");
      this.scgdSelected=false;
      this.bgSelected = false;
    },
    /**查询用户列表*/
    getUsers(){
      this.userSelect=true;
      listUser(this.userName).then(response => {
        this.userList = response.rows;
        this.userTotal = response.total;
        console.log(response.rows)
      });
    },
    /**判断性别*/
    getSex(row, column, cellValue){
      if (cellValue=="1"){
        return "女";
      }else{
        return "男";
      }
    },
    //订单性质
    orderAbility(row, column, cellValue){
      if (cellValue=='1'){
        return "销售";
      }else if(cellValue=='2'){
        return "样品";
      }else{
        return "研发";
      }
    },
    //优先级
    gdLevel(row, column, cellValue){
      if (cellValue=="1"){
        return "一级";
      }else{
        return  "二级";
      }
    },
    //查询生产订单
    getScdd(){
      this.ddSelect=true;
      listForm(this.scddCode).then(response => {
        this.scddList = response.rows;
        this.scddTotal = response.total;
        console.log(this.formList)
      });
    },

    //工单状态
    gdStatus(row, column, cellValue){
      if (cellValue=="1"){
        return "生产中";
      }else if(cellValue=="2"){
        return  "未投产";
      }else if(cellValue=="3"){
        return "已投产";
      }else if(cellValue=="4"){
        return "暂停中";
      }else if(cellValue=="5"){
        return "已完工";
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        gdCode: null,
        gdGoodlevel: null,
        gdStatus: 2,
        ddCode: null,
        htCode: null,
        cpCode: null,
        scddProductionOrderForm:{cpProduct:{cpName:null,cpType:null,cpCode:null},ksMerchant:{merchantsName:null},ddCode:null,htCode:null},
        responsibility:null,
        ksCode: null,
        workNum: null,
        jhTime: null,
        gdCppcCode:null,
        startTime: null,
        endTime: null,
        other: null,
        isUse: 1,
        isDelete: 1,
        percent: 0,
        scgdCreate: 'admin',
        createTime: Date.now(),
        updateTime: null
      };
      this.gdCode=null;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.gdCode)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加生产工单";
    },
    /** 修改工单状态 */
    updateGdStatus(row,gdStatus){
      let status='';
      if (gdStatus=="开工"||gdStatus=="恢复"){
        status='1';
      }else if(gdStatus=="暂停"){
        status='4';
      }else if(gdStatus=='完工'){
        status='5';
      }
      const gdCode=row.gdCode;
      updateGdStatus(gdCode,status).then(response=>{
        this.$modal.msgSuccess(gdStatus+"成功");
        this.getList();
      })
    },
    //订单类型
    orderType(row, column, cellValue){
      if (cellValue=="1"){
        return "普通订单";
      }else if(cellValue=="2"){
        return "OEM订单";
      }else{
        return "在库订单";
      }
    },
    /** 生产报工 */
    gdReport(row){
      this.bgSelected=true;
    },
    /** 物料需求 */
    getWlList(row){
      this.gdCode=row.gdCode;
      const gdCode=row.gdCode;
      this.rwNum=row.workNum;
      this.dialogVisible=true;
      listBom(gdCode).then(response=>{
        this.bomData=response.data;
        console.log(this.bomData);
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const gdCode = row.gdCode || this.ids
      getOrder(gdCode).then(response => {
        this.form = response.data;
        this.form.gdCode=row.gdCode;
        this.scgdSelected = true;
        this.title = "修改生产工单";
      }).then(()=>{
        listBom(gdCode).then(response=>{
          console.log(gdCode)
          this.bomData=response.data;
          console.log(this.bomData);
        })
      }).then(()=>{
        const cpCode=row.cpCode;
        getCpAttribute(cpCode).then(response=>{
          console.log(response.data);
          this.attributesData=response.data;
        })
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.scddProductionOrderFormList = this.scddProductionOrderFormList;
          if (this.form.gdCode != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const gdCodes = row.gdCode || this.ids;
      this.$modal.confirm('是否确认删除生产工单编号为"' + gdCodes + '"的数据项？').then(function() {
        return delOrder(gdCodes);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 生产订单序号 */
    rowScddProductionOrderFormIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 生产订单添加按钮操作 */
    handleAddScddProductionOrderForm() {
      let obj = {};
      obj.ddLevel = "";
      obj.ddStatus = "";
      obj.ddTypecode = "";
      obj.ddGoodcode = "";
      obj.ksCode = "";
      obj.htCode = "";
      obj.cpCode = "";
      obj.ddNum = "";
      obj.jhDate = "";
      obj.startTime = "";
      obj.finishTime = "";
      obj.other = "";
      obj.isUse = "";
      obj.isDelete = "";
      obj.scddCreate = "";
      obj.createTime = "";
      obj.updateTime = "";
      this.scddProductionOrderFormList.push(obj);
    },
    /** 生产订单删除按钮操作 */
    handleDeleteScddProductionOrderForm() {
      if (this.checkedScddProductionOrderForm.length == 0) {
        this.$modal.msgError("请先选择要删除的生产订单数据");
      } else {
        const scddProductionOrderFormList = this.scddProductionOrderFormList;
        const checkedScddProductionOrderForm = this.checkedScddProductionOrderForm;
        this.scddProductionOrderFormList = scddProductionOrderFormList.filter(function(item) {
          return checkedScddProductionOrderForm.indexOf(item.index) == -1
        });
      }
    },
    /** 复选框选中数据 */
    handleScddProductionOrderFormSelectionChange(selection) {
      this.checkedScddProductionOrderForm = selection.map(item => item.index)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/order/export', {
        ...this.queryParams
      }, `order_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style>
.el-date-editor.el-input, .el-date-editor.el-input__inner{
  width: 202px;

}
.table-qyh input{
  width:70%;
}
#other{
  width: 252%;
  height: 80px;
}

.dialog-content {
  max-height: 600px; /* 根据需要调整 */
  overflow-y: auto;
  padding-right: 15px; /* 为了避免滚动条覆盖内容 */
}
.dialog-footer {
  text-align: right;
}


</style>
